//
//  FeedbackView.m
//  xpkc
//
//  Created by TopSage iOS on 14-8-21.
//  Copyright (c) 2014年 wanmeizty. All rights reserved.
//

#import "FeedbackView.h"

@implementation FeedbackView 
{
    UILabel *_placeholderLabel;
}

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
        [self creatView];
    }
    return self;
}
- (void)creatView{
    
    self.deviceLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 5, self.bounds.size.width-20, 30)];
    self.deviceLabel.numberOfLines=0;
//    [self.deviceLabel setText:@"设备:iPhone6 系统:iOS7.1.2 客户端版本:2.1.0"];
    [self.deviceLabel setTextAlignment:NSTextAlignmentCenter];
    [self.deviceLabel setTextColor:[UIColor darkGrayColor]];
    [self.deviceLabel setFont:[UIFont systemFontOfSize:12]];
    
    UIImageView *imageview = [[UIImageView alloc]initWithFrame:CGRectMake(10, 40, self.bounds.size.width-20, 220)];
    imageview.image = [UIImage imageNamed:@"register_bg"];
    
    _textView=[[UITextView alloc]initWithFrame:CGRectMake(10, 30, self.bounds.size.width-20, 220)];
    _textView.backgroundColor=[UIColor clearColor];
    _textView.delegate = self;
    [_textView setFont:FONT_SYS_NORMAL];
    
    _placeholderLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 40, SCREEN_WIDTH-100, 40)];
    _placeholderLabel.text = @"请您输入宝贵的意见，我们将为了您的完美体验而不断努力。";
    [_placeholderLabel setFont:[UIFont systemFontOfSize:14]];
    [_placeholderLabel setNumberOfLines:0];
    [_placeholderLabel setTextColor:[UIColor lightGrayColor]];
    [_placeholderLabel setBackgroundColor:[UIColor clearColor]];
    
    self.cameraButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.cameraButton setFrame:CGRectMake(self.bounds.size.width-70, 40, 50, 50)];
    [self.cameraButton setBackgroundImage:[UIImage imageNamed:@"camera.png"] forState:UIControlStateNormal];
    [self.cameraButton addTarget:self action:@selector(cameraButtonClicked) forControlEvents:UIControlEventTouchUpInside];
    UILabel *tipLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.bounds.size.width-70, 90, 50, 20)];
    [tipLabel setText:@"添加图片"];
    [tipLabel setTextAlignment:NSTextAlignmentCenter];
    [tipLabel setTextColor:[UIColor darkGrayColor]];
    [tipLabel setFont:[UIFont systemFontOfSize:12]];
    
    self.emailLabel = [[UITextField alloc] initWithFrame:CGRectMake(_textView.frame.origin.x+30, _textView.frame.size.height+40, self.bounds.size.width-2*(_textView.frame.origin.x+30), 30)];
//    [self.emailLabel setText:@"您的邮箱地址:12347812934@qq.com"];
    self.emailLabel.placeholder=@"请输入您的邮箱地址";
    [self.emailLabel setTextAlignment:NSTextAlignmentCenter];
    [self.emailLabel setTextColor:[UIColor darkGrayColor]];
    [self.emailLabel setFont:[UIFont systemFontOfSize:14]];
    [self.emailLabel setBackgroundColor:[UIColor whiteColor]];
    self.emailLabel.layer.cornerRadius = 5;
    self.emailLabel.layer.masksToBounds = YES;
    
    _button=[UIButton buttonWithType:UIButtonTypeCustom];
    _button.frame=RECT(_textView.frame.origin.x+30, _textView.frame.origin.y+_textView.frame.size.height+50, self.bounds.size.width-2*(_textView.frame.origin.x+30), 40);
    [_button setTitle:@"提   交" forState:UIControlStateNormal];
    [_button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    _button.backgroundColor = GreenColor;
    _button.layer.cornerRadius = 5;
    
    [self addSubview:self.deviceLabel];
    [self addSubview:imageview];
    [self addSubview:_textView];
    [self addSubview:_placeholderLabel];
    [self addSubview:self.cameraButton];
    [self addSubview:tipLabel];
    [self addSubview:self.emailLabel];
    [self addSubview:_button];

}

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    [self.emailLabel resignFirstResponder];
    [self.textView resignFirstResponder];
}
- (void)cameraButtonClicked {
    
    
}

#pragma  mark - UITextView Delegate
- (void)textViewDidChange:(UITextView *)textView {
    if(textView.text.length == 0) {
        _placeholderLabel.text = @"请您输入宝贵的意见，我们将为了您的完美体验而不断努力。";
    } else {
        _placeholderLabel.text = @"";
    }
}


/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
    // Drawing code
}
*/

@end
